﻿Public Class Form1

    Dim PrevClipboardcontentStr As String = ""
    Public Shared RowCount As Integer = 0
    Dim ClipArray As String()

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Not Clipboard.GetText = Nothing Then
            ClipGrid.Rows.Insert(RowCount, ClipGrid.Rows.Count + 1, Clipboard.GetText, System.DateTime.Now.ToShortTimeString)
            PrevClipboardcontentStr = Clipboard.GetText
        End If
        
    End Sub

    Private Sub CoreTimer_Tick(sender As Object, e As EventArgs) Handles CoreTimer.Tick
        Dim newrow As New DataGridViewRow

        For i = 0 To (ClipGrid.Rows.Count - 1) Step 1
            newrow.SetValues(i, Clipboard.GetText)

            If Not ClipGrid.Rows.Contains(newrow) Then

                If Not PrevClipboardcontentStr = Clipboard.GetText AndAlso Not Clipboard.GetText = Nothing Then
                    PrevClipboardcontentStr = Clipboard.GetText
                    ClipGrid.Rows.Insert(RowCount, ClipGrid.Rows.Count + 1, Clipboard.GetText, System.DateTime.Now.ToShortTimeString)
                End If

            End If
            ToolStripStatusLabel2.Text = i
        Next

    End Sub



    Private Sub EditToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EditToolStripMenuItem.Click
        Try
            RowCount = ClipGrid.SelectedRows.Count
            Edit.Show()
        Catch ex As Exception

        End Try
    End Sub

    Public Shared Sub UpdateGrid(ByVal RowCount As Integer, ByVal text As String, Optional time As String = "", Optional DataType As String = "")
        Form1.ClipGrid.Rows.RemoveAt(RowCount)
        Form1.ClipGrid.Rows.Insert(RowCount, RowCount, text, time)
    End Sub


End Class
